package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"seckill-system/handler"
	"seckill-system/model"
	"seckill-system/util"
)

func main() {
	util.InitLog("log")
	db:=model.InitDB()
	giftDAO:=model.NewGormGiftDAO(db)
	inventoryDAO:=model.NewGormInventoryDAO(db)
	giftHandler:=handler.NewGiftHandler(*giftDAO, *inventoryDAO)

	r:=gin.Default()
	r.Static("/js", "views/js")
	r.Static("/img", "views/img")
	r.StaticFile("/favicon.ico", "views/img/favicon.ico")
	r.LoadHTMLFiles("views/lottery.html")

	r.GET("/", func(ctx *gin.Context){
		ctx.HTML(http.StatusOK, "lottery.html", nil)
	})
	r.GET("/gifts", giftHandler.GetAllGifts)

	r.Run(":8080")
}
